package engine.light;

import java.nio.FloatBuffer;

import org.lwjgl.BufferUtils;

import static org.lwjgl.opengl.GL11.*;

public class EnvironmentLight extends Light{

	private FloatBuffer ambient;
	private FloatBuffer direction;
	
	public EnvironmentLight() {
		super();
		
		ambient = BufferUtils.createFloatBuffer(4);
		ambient.put(3, 1);
		direction = BufferUtils.createFloatBuffer(4);
		direction.put(3, 0);
	}
	
	public FloatBuffer getAmbient() {
		return ambient;
	}
	
	public void setAmbient(float r, float g, float b) {
		ambient.put(0, r);
		ambient.put(1, g);
		ambient.put(2, b);
	}
	
	public FloatBuffer getDirection() {
		return direction;
	}
	
	public void setDirection(float x, float y, float z) {
		direction.put(0, x);
		direction.put(1, y);
		direction.put(2, z);
	}
	
	@Override
	public void apply(int lightSource) {
		super.apply(lightSource);
		
		ambient.rewind();
		direction.rewind();
		
		glLight(lightSource, GL_AMBIENT, ambient);
		glLight(lightSource, GL_POSITION, direction);
	}
}
